<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>抽奖</title>
</head>
<style>
    body{
        background: rgb(151, 95, 95);
    }
</style>
<body>
    <button id="go">开始Go</button>
    <button id="stop">停止</button>
    <h4 id="gogo">开始抽奖</h4>

    <script>

      var tag=document.getElementById('gogo');
      var  go=document.getElementById('go');
      var  stop=document.getElementById('stop');
      var  timer;

      var list=['小明','小红','小亮','小梁','小红','小红','小红'];

      console.log(list[0]);

      console.log(list.length);

      go.onclick=function(){

          clearInterval(timer);

          timer=setInterval(function(){

          var n=parseInt(Math.random()*list.length);

          tag.innerHTML=list[n]
        },120)
      }
      
      stop.onclick=function(){
          clearInterval(timer);
      }
    </script>
</body>
</html>